<?php
namespace App\Http\Controllers;

use App\Model\Blog;
use Carbon\Carbon;
use Symfony\Component\HttpFoundation\Request;

class HomeController extends Controller {

    function index(Request $request) {
        $blogs = Blog::paginate(10);
        foreach ($blogs as $blog) {
            $blog->create_at = Carbon::parse($blog->create_at, 'Asia/Shanghai')->diffForHumans();
        }

        return view('blog', ['blogs' => $blogs]);
    }

    function test(Request $request) {
        $blogs = Blog::paginate(10);
        foreach ($blogs as $blog) {
            $blog->create_at = Carbon::parse($blog->create_at, 'Asia/Shanghai')->diffForHumans();
        }

        return view('test', ['blogs' => $blogs]);
    }
}
